import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import shopView from '../views/shopView.vue'
import shopdetail from "../views/shopdetail.vue"
import detail from "../views/detail.vue"
import cotrshop from "../views/cotrshop.vue"
// import ShoppingCart from "../views/ShoppingCart.vue"
import NProgress from 'nprogress'

import 'nprogress/nprogress.css'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
  
    {
      path: '/',
      name: 'shop',
      component: shopView
    },
    {
      path: '/detail',
      name: 'detail',
      component: shopdetail
    },
    {
      path: '/shopdetail',
      name: 'shopdetail',
      component: detail
    },
    
    {
      path: '/cotrshop',
      name: 'cotrshop',
      component: cotrshop
    },
    
  ]
})



//全局守卫
router.beforeEach((to,from,next)=>{
  NProgress.start()
	next()
})

router.beforeResolve((to,from,next)=>{
	next()
})

router.afterEach((to,from)=>{
  NProgress.done()
})

export default router
